
package com.hyst.seviceImpl;

import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.hyst.domain.Lesson;
import com.hyst.repository.LessonMapper;
import com.hyst.service.LessonService;
import com.hyst.utils.UuidTool;

/**
 * @Description:
 * @Date：2018年08月26日 
 * @author： dy 
 * @version ：1.0 1.[2018年08月26日]
 */
@Service
public class LessonServiceImpl implements LessonService {

	@Autowired
	private LessonMapper mapper;

	@Override
	public Page<Lesson> list(final Lesson lesson) {
		final Page<Lesson> page = PageHelper.startPage(lesson.getPageNum(), lesson.getPageSize());
		mapper.select(lesson);
		return page;
	}

	@Override
	public Lesson insert(final Lesson lesson) {
		mapper.insertSelective(lesson);
		return lesson;
	}

	@Override
	public Lesson getByPriKey(final Integer id) {
		final Lesson lesson = mapper.selectByPrimaryKey(id);
		return lesson;
	}

	@Override
	public Lesson updateSelective(final Lesson lesson) {
		mapper.updateByPrimaryKeySelective(lesson);
		return lesson;
	}

	@Override
	public Lesson update(final Lesson lesson) {
		mapper.updateByPrimaryKey(lesson);
		return lesson;
	}

	@Override
	public Lesson delete(final Integer id) {
		Lesson lesson=mapper.selectByPrimaryKey(id);
		lesson.setIsDelete(1);
		mapper.updateByPrimaryKey(lesson);
		return lesson;
	}

	@Override
	public List<Map> getSelect2Data() {
		return mapper.getSelect2Data();
	}

	@Override
	public Page<Lesson> getLessonsHasLevel() {
		Page<Lesson> page=PageHelper.startPage(1,Integer.MAX_VALUE);
		List <Lesson>list=mapper.getLessonsHasLevel();
		return page;
	}

}
